package com.sloera.nowcoder;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * class com.sloera.nowcoder
 * user sloera
 * date 2022/2/28
 */
public class HJ94 {
    public static void main(String[] args) {
        final Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            handle(in);
        }
    }

    private static void handle(Scanner in) {
        int candidate = 0;
        if (in.hasNextInt()) {
            candidate = in.nextInt();
        }
        String[] names = new String[candidate];
        for (int i = 0; i < candidate; i++) {
            names[i] = in.next();
        }
        final HashSet<String> nameSet = new HashSet<>(Arrays.asList(names));
        final HashMap<String, Integer> nameCount = new HashMap<>();
        AtomicInteger invalid = new AtomicInteger();
        int voteNum = 0;
        if (in.hasNextInt()) {
            voteNum = in.nextInt();
        }
        for (int i = 0; i < voteNum; i++) {
            String x = in.next();
            if (nameSet.contains(x)) {
                nameCount.put(x, Optional.ofNullable(nameCount.get(x)).orElse(0) + 1);
            } else {
                invalid.getAndIncrement();
            }
        }
        for (int i = 0; i < names.length; i++) {
            System.out.println(names[i] + " : " + Optional.ofNullable(nameCount.get(names[i])).orElse(0));
        }
        System.out.println("Invalid : " + invalid);
    }
}
